package com.vanysoft.business.data.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.vanysoft.business.data.dao.PlantMapper;
import com.vanysoft.business.data.entity.Plant;
import com.vanysoft.business.data.service.PlantService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 工厂信息表 服务实现类
 * </p>
 *
 * @author YangLei
 * @since 2018-07-01
 */
@Service
public class PlantServiceImpl extends ServiceImpl<PlantMapper, Plant> implements PlantService {

    @Override
    public Page<Plant> selectPage(Page page, String key) {
        EntityWrapper<Plant> wrapper = new EntityWrapper<Plant>();
        wrapper.setEntity(new Plant());
        wrapper.eq("is_enable", "1");
        if (StringUtils.isNotEmpty(key)) {
            wrapper.andNew().like("plant_code", key).or().like("english_name", key).or().like("chinese_name", key);
        }
        return selectPage(page, wrapper);
    }
}
